#!/bin/sh
# This regression test is a part of SIPp.
# With -rfc3339, -trace_shortmsg dates the messages received like those
# sent.
. "`dirname "$0"`/../functions"; init

rm -f ./*_shortmessages.log
sippbg -sn uas -i 127.0.0.1 -p 5070 -m 1
sippfg -sn uac -i 127.0.0.1 -p 5071 -m 1 127.0.0.1:5070 \
    -trace_shortmsg -rfc3339 -timeout 6 -timeout_error >/dev/null 2>&1
status=$?
log=`cat ./*_shortmessages.log 2>/dev/null`
rm -f ./*_shortmessages.log

received=`echo "$log" | grep -c '	R	'`
rfc=`echo "$log" | grep -c '^[0-9-]*T[0-9:.]*[-+Z]'`
lines=`echo "$log" | grep -c .`

if test $status -ne 0; then
    fail "UAC failed with $status"
elif test $received -eq 0; then
    fail "no received messages logged"
elif test $rfc -ne $lines; then
    fail "not all lines in RFC 3339: $log"
else
    ok
fi
